home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / TEST / LINE_PAR.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  2.9 KB  |  97 lines

  1. /*
  2.  * $Id: line_parent.java,v 1.11 1996/10/03 19:46:51 hudson Exp $
  3.  * $Author: hudson $
  4.  */
  5.  
  6. package sub_arctic.test;
  7.  
  8. import sub_arctic.lib.interactor_applet;
  9. import sub_arctic.lib.line_display;
  10. import sub_arctic.output.drawable;
  11. import sub_arctic.input.simple_draggable;
  12. import sub_arctic.input.event;
  13. import sub_arctic.input.pressable;
  14. import sub_arctic.lib.manager;
  15. import sub_arctic.lib.base_interactor;
  16.  
  17. public class line_parent 
  18. extends base_interactor implements pressable, simple_draggable {
  19.   public line_parent() 
  20. {
  21.     super(0,0);
  22.     /* make us able to be a parent */
  23.     setup_for_children(10);
  24.     /* we assume the parent will constrain us to fit in the UI */
  25.     arrowheads=1;
  26.   }
  27.   public boolean press(event e, Object ui) {
  28.     /* make us the drag focus */
  29.     manager.simple_drag_focus.set_focus_to(this,e,new line_parent_status());
  30.     return true;
  31.   }
  32.   public boolean release(event e, Object ui) {
  33.     /* can't do anything, the focus overrides this and this doesn't
  34.      get called*/
  35.     return false;
  36.   }
  37.   /* just stash where the original point was */
  38.   public boolean drag_start(event e, Object ui){
  39.     line_parent_status stat = (line_parent_status)ui;
  40.     stat.x_start=e.local_x();
  41.     stat.y_start=e.local_y();
  42.     stat.the_line = new line_display(stat.x_start, stat.y_start, 
  43.                      stat.x_start, stat.y_start, arrowheads, angle, length);
  44.     add_child(stat.the_line);
  45.     return true;
  46.   }
  47.   public boolean drag_feedback(event evt, Object ui) {
  48.     line_parent_status stat = (line_parent_status)ui;
  49.     /* reset the coords to reflect this drag */
  50.     stat.the_line.set_coords(stat.x_start,stat.y_start, 
  51.                  evt.local_x(),evt.local_y());
  52.     return true;
  53.   }
  54.   public boolean drag_end(event evt, Object ui) {
  55.     line_parent_status stat = (line_parent_status)ui;
  56.     /* reset the coords to reflect the new endpoint */
  57.     stat.the_line.set_coords(stat.x_start, stat.y_start, 
  58.                  evt.local_x(),evt.local_y());
  59.     damage_self();
  60.     return true;
  61.   }
  62.   int arrowheads;
  63.   public void set_arrow_heads(int a) {
  64.     arrowheads=a;
  65.   }
  66.   int length;
  67.   public void set_arrow_head_length(int l) {
  68.     length=l;
  69.   }
  70.   int angle;
  71.   public void set_arrow_head_angle(int a) {
  72.     angle=a;
  73.   }
  74. }
  75.  
  76. /* "local" class to hold our state information during drag */
  77. class line_parent_status {
  78.   line_display the_line;
  79.   int x_start, y_start;
  80. }
  81. /*=========================== COPYRIGHT NOTICE ===========================
  82.  
  83. This file is part of the subArctic user interface toolkit.
  84.  
  85. Copyright (c) 1996 Scott Hudson and Ian Smith
  86. All rights reserved.
  87.  
  88. The subArctic system is freely available for most uses under the terms
  89. and conditions described in 
  90.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  91. and appearing in full in the lib/interactor.java source file.
  92.  
  93. The current release and additional information about this software can be 
  94. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  95.  
  96. ========================================================================*/
  97.